package fifis.mvc.controller;

import com.jme3.scene.Node;
import fifis.game.common.MyObservable;
import fifis.game.common.ObservableArgument;
import fifis.mvc.model.FModel;
import fifis.mvc.view.FView;
import org.apache.log4j.Logger;

/**
 *
 * @author porfiriopartida
 */
public abstract class FController extends MyObservable {
    protected final static Logger log4j = Logger.getLogger(FController.class);
    static final long serialVersionUID = 1L;
    
    public static final int NAME_CHANGED = 0;
    private FModel model;
    private FView view;
//    AssetManager assetManager;

//    public FController(FModel model, FView view){
//        this.model = model;
//        this.view = view;
//    }
//    public FController(){
//        this(null,null);
//    }
//    abstract protected void initModel();
//    abstract protected void initView();
    public FModel getModel() {
        return model;
    }

    public void setModel(FModel model) {
        this.model = model;
    }

    public Node getNode() {
        return view.getNode();
    }

    public FView getView() {
        return view;
    }

    public void setView(FView view) {
        this.view = view;
    }
    public abstract boolean isAlive();
    /**
     * Called by the logic to every actor
     */
    public abstract void update();

    public void setName(String name) {
        ObservableArgument oa = new ObservableArgument(NAME_CHANGED, model.getName(), name);
        notifyObservers(oa);
        model.setName(name);
    }

    public String getName() {
        return getNode().getName();
    }
}
